package com.lee;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.IntStream;

/**
 * @Description TODO
 */
public class VirtualThreadTest {
    public static void main(String[] args) {
        var executorService = Executors.newVirtualThreadPerTaskExecutor();
//        IntStream.rangeClosed(1,5_000_000).forEach(i-> executorService.submit(() -> {
        IntStream.rangeClosed(1,10).forEach(i-> executorService.submit(() -> {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
            System.out.println(Thread.currentThread() + " " + i);
        }));
        executorService.close();
    }
}
